<?php /*a:3:{s:79:"C:\Users\pc306\Desktop\Projects\learn-php\app\index\view\weathercity.index.html";i:1594904670;s:36:"../app/index/view/public.header.html";i:1591618155;s:36:"../app/index/view/public.footer.html";i:1589786048;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Admin</title>
    <script type="text/javascript" src="/plug/layui/layui.js"></script>
    <script type="text/javascript" src="/static/script/common.js"></script>
    <script type="text/javascript" src="/static/script/moment.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/plug/awesome/css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="/plug/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/common.css" />
</head>
<body>

<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form layui-form-pane mt8">
            <div class="layui-form-item">
                <div class="layui-input-inline">
                    <input class="layui-input" name="keyword" id="keyword" type="text" placeholder="请输入关键字" value="<?php echo htmlentities($keyword); ?>" autocomplete="off" lay-verify="title"/>
                </div>
                <div class="layui-btn-group">
                    <a class="layui-btn layui-btn-primary" id="search"><i class="fa fa-search fa-fw"></i> 搜索数据</a>
                    <a class="layui-btn layui-btn-primary" id="add"><i class="fa fa-plus fa-fw"></i> 添加数据</a>
                    <a class="layui-btn layui-btn-primary" id="batch"><i class="fa fa-xing fa-fw"></i> 批量删除</a>
                    <a class="layui-btn layui-btn-primary" id="modify"><i class="fa fa-edit fa-fw"></i> 批量修改</a>
                </div>
            </div>
        </form>
        <table class="layui-table" lay-data="{height: 'full-78', cellMinWidth: 80,url:'http://127.0.0.1/index.php/index/weathercity/getlist/?keyword=<?php echo htmlentities($keyword); ?>',
        page:true,limit:'100',limits:[100,200,300,400],skin:'line',even:'true',id:'table'}" lay-filter="table1">
            <thead>
            <tr>
                <th lay-data="{checkbox:true,fixed:true}"></th>
                <th lay-data="{field:'id'}">区域ID</th>
                <th lay-data="{field:'provinceZh'}">省份</th>
                <th lay-data="{field:'leaderZh'}">地区</th>
                <th lay-data="{field:'cityZh'}">城市</th>
                <th lay-data="{field:'lat'}">经度</th>
                <th lay-data="{field:'lon'}">维度</th>
                <th lay-data="{fixed:'right',align:'center',width:120,toolbar:'#toolbar'}">操作</th>
            </tr>
            </thead>
        </table>
    </div>
</div>
<script type="text/html" id="toolbar">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-xs" lay-event="delete">删除</a>
</script>
<script type="text/javascript">
    layui.use(["layer", "form", "table", "upload", "element", "laydate"], function () {
        layui.jquery("#search").click(function () {
            location.href = "http://127.0.0.1/index.php/index/weathercity/index/?keyword=" + layui.jquery("#keyword").val();
        });
        layui.jquery("#add").click(function () {
            showIFrame("添加数据", "http://127.0.0.1/index.php/index/member/add/");
        });
        layui.jquery("#batch").click(function () {
            let id = "";
            let data = layui.table.checkStatus("table").data;
            if (data.length === 0) {
                showMessage("尚未选择数据~", 2);
                return;
            }
            layui.jquery.each(data, function (position, item) {
                id = id + item.member_id + ',';
            });
            get("http://127.0.0.1/index.php/index/member/batch/?id=" + id, function (result) {
                closeAll();
                if (jsonFailure(result)) {
                    showMessage(jsonMsg(result), 2);
                    return;
                }
                showMessage("删除成功~", 1, function () {
                    location.reload();
                });
            });
        });
        layui.jquery("#modify").click(function () {
            let id = "";
            let data = layui.table.checkStatus("table").data;
            if (data.length === 0) {
                showMessage("尚未选择数据~", 2);
                return;
            }
            layui.jquery.each(data, function (position, item) {
                id = id + item.member_id + ',';
            });
            showIFrame("批量修改", "http://127.0.0.1/index.php/index/member/modify/?id=" + id);
        });
        layui.table.on("tool(table1)", function (object) {
            if (object.event === "edit") {
                showIFrame("编辑数据", "http://127.0.0.1/index.php/index/member/edit/?id=" + object.data.member_id);
            }
            if (object.event === "delete") {
                get("http://127.0.0.1/index.php/index/member/delete/?id=" + object.data.member_id, function (result) {
                    closeAll();
                    if (jsonFailure(result)) {
                        showMessage(jsonMsg(result), 2);
                        return;
                    }
                    showMessage("删除成功~", 1, function () {
                        location.reload();
                    });
                });
            }
        });
    });
</script>
</body>
</html>

